package com.parking.platform.controller;


import com.parking.common.core.model.Result;
import com.parking.common.web.aop.Permission;
import com.parking.platform.dto.InterfaceDto;
import com.parking.platform.dto.InterfaceDtos;
import com.parking.platform.form.UpInterfaceForm;
import com.parking.platform.form.UpRoleResourceForm;
import com.parking.platform.service.PlatformInterfaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 香菜狗带
 * @since 2023年12月06日
 */
@RestController
@RequestMapping("/platformInterface")
@Api(tags = "接口资源权限接口")
public class PlatformInterfaceController {

    @Resource
    private PlatformInterfaceService platformInterfaceService;
    /***
     * 修改动态接口资源
     * 参数：
     * platformRoleId：角色Id
     * platformInterfaceId：接口Id
     */
    @ApiOperation("修改动态接口资源")
    @Permission(resources = "/upPlatformInterface.platform")
    @PostMapping("/upPlatformInterface.platform")
    public Result  upPlatformInterface(@RequestBody List<UpInterfaceForm> form){
        platformInterfaceService.upPlatformInterface(form);
        return Result.getResult().setCode(200).setMessage("修改动态接口资源成功");
    }
    /***
     * 查询全部接口资源
     * 参数：
     * platformRoleId：角色Id
     *
     */
    @ApiOperation("查询全部接口资源")
    @GetMapping("/findInterfaceAll.platform")
    @Permission(resources = "/findInterfaceAll.platform")
    public Result  findInterfaceAll(Integer platformRoleId){
        InterfaceDtos dto=platformInterfaceService.findInterfaceAll(platformRoleId);
        return Result.getResult(InterfaceDtos.class).setCode(200).setMessage("查询全部接口资源成功").setData(dto);
    }

}

